/*
 * @Author: Tim
 * @Date: 2020-07-16 15:30:40
 * @LastEditTime: 2020-09-18 09:48:08
 * @LastEditors: Please set LastEditors
 * @Description: storage封装合集
 * @FilePath: /afire/src/utils/storage.js
 */

export default class Storage {

  /**
   * @description 获取本地storage
   * @param {*} key
   */
  static get(key) {
    if (!key) return null;
    return uni.getStorageSync(key);
  }

  /**
   * @description 设置本地的storage
   * @param {*} key
   * @param {*} data : {string/object}
   */
  static set(key, data) {
    if (!key || !data) return;

    uni.setStorageSync(key, data);
  }

  /**
   * @description 清除本地的storage
   * @param {*} key
   */
  static clear(key) {
    if (!key) {
      return;
    }
    uni.removeStorageSync(key);
  }

  /**
   * @description 清除本地所有storage
   */
  static clearAll() {
    uni.clearStorageSync();
  }
};